<?php
declare (strict_types = 1);

namespace app\middleware;

use think\Request;
use app\Exception\AuthTokenException;
use app\services\TokenService;

class AuthToken
{
    public function handle(Request $request, \Closure $next, bool $force = true)
    {
        if(!$request->header('Authorization')){
            throw new AuthTokenException(['status' => 401, 'errorMsg' => '请登录后在操作', 'errorCode' => 40200]);
        }
    
        TokenService::parseToken();
        return $next($request);
    }
}